<template>
  <basic-container :btnFlag=true>
    <div class="card-border">
      <card-header :header-data="headerData"></card-header>
      <el-form
        label-width="130px"
        :model="projectForm"
        style="padding-right: 30px;"
        :rules="addProgramFormRules"
        ref="projectForm"
      >
        <el-row>
          <el-col :span="16" style="margin-top: 27px;">
            <el-form-item class="form-item" label="规划名称 :" prop="planningTitle">
              <el-input
                placeholder="请输入规划名称"
                v-model="projectForm.planningTitle"
                :disabled="true"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-button size="small" type="primary" style="margin-left: 10px;margin-top: 31px" @click="choosePlanning()">
              选择规划
            </el-button>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="22">
            <el-form-item class="form-item" label="方案描述 :" prop="description">
              <el-input
                type="textarea"
                :autosize="{ minRows: 4, maxRows: 4}"
                placeholder="请输入方案描述"
                v-model="projectForm.description"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="22">
            <el-form-item class="form-item" label="相关附件:">
              <el-upload
                class="upload-demo"
                ref="uploadrelated"
                action="string"
                :http-request="submitUploadMixin"
                :on-preview="handlePreviewMixin"
                :on-remove="handleRemoveMixin"
                :file-list="fileListMixin"
                :auto-upload="true"
                :on-change="fileChangeMixin">
                <el-button slot="trigger" size="small" type="primary">点击上传</el-button>
              </el-upload>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <!--指标，任务，项目配置-->
      <el-collapse v-model="activeNames" style="margin-top:2rem;">
        <el-collapse-item name="1">
          <template slot="title">
            <div class="card-header collapse-header">
              <div class="head-title collapse-title">指标</div>
            </div>
          </template>
          <div style="float: right;margin:10px 5px -3px 0px">
            <el-button type="primary" size="mini" @click="addNorm('0')">添加指标</el-button>
          </div>
          <avue-crud :data="normListDataPage"
                     :option="normTableOption"
                     :page="normPage"
                     :table-loading="normTableLoading"
                     @on-load="getNormList"
                     @size-change="normsizeChange"
                     @current-change="normcurrentChange"
                     class="avuecrud">
            <template slot-scope="scope" slot="menu">
              <div class="menu-title" @click.stop="normDelete(scope.row,scope.index)">
                <i class="iconfont iconalter icon-warning"></i>
                <p class="menu-title-text">删除</p>
              </div>
              <!-- <div class="menu-title" @click.stop="addTargetDialogNorm(scope.row,scope.index)">
                <i class="iconfont iconview icon-primary"></i>
                <p class="menu-title-text">阶段性目标</p>
              </div> -->
            </template>
          </avue-crud>
        </el-collapse-item>
        <el-collapse-item name="2">
          <template slot="title">
            <div class="card-header collapse-header">
              <div class="head-title collapse-title">任务</div>
            </div>
          </template>
          <div style="float: right;margin:10px 5px -3px 0px">
            <el-button type="primary" size="mini" @click="addNorm('1')">添加任务</el-button>
          </div>
          <avue-crud :data="taskListDataPage"
                     :option="taskTableOption"
                     :page="taskPage"
                     :table-loading="taskTableLoading"
                     @on-load="getTaskList"
                     @size-change="tasksizeChange"
                     @current-change="taskcurrentChange"
                     class="avuecrud">
            <template slot-scope="scope" slot="menu">
              <div class="menu-title" @click.stop="taskDelete(scope.row,scope.index)">
                <i class="iconfont iconalter icon-warning"></i>
                <p class="menu-title-text">删除</p>
              </div>
              <!--<div class="menu-title" @click.stop="addTargetDialogTask(scope.row,scope.index)">-->
              <!--<i class="iconfont iconview icon-primary"></i>-->
              <!--<p class="menu-title-text">阶段性目标</p>-->
              <!--</div>-->
            </template>
          </avue-crud>
        </el-collapse-item>
        <el-collapse-item name="3">
          <template slot="title">
            <div class="card-header collapse-header">
              <div class="head-title collapse-title">项目</div>
            </div>
          </template>
          <div style="float: right;margin:10px 5px -3px 0px">
            <el-button type="primary" size="mini" @click="addNorm('2')">添加项目</el-button>
          </div>
          <avue-crud :data="projectListDataPage"
                     :option="projectTableOption"
                     :page="projectPage"
                     :table-loading="projectTableLoading"
                     @on-load="getProjectList"
                     @size-change="projectsizeChange"
                     @current-change="projectcurrentChange"
                     class="avuecrud">
            <template slot-scope="scope" slot="menu">
              <div class="menu-title" @click.stop="projectDelete(scope.row,scope.index)">
                <i class="iconfont iconalter icon-warning"></i>
                <p class="menu-title-text">删除</p>
              </div>
              <!-- <div class="menu-title" @click.stop="addTargetDialogProject(scope.row,scope.index)">
                <i class="iconfont iconview icon-primary"></i>
                <p class="menu-title-text">阶段性目标</p>
              </div> -->
            </template>
          </avue-crud>
        </el-collapse-item>
      </el-collapse>
      <div class="form-submit">
        <el-button type="primary" @click.stop="commitList()">提 交</el-button>
        <el-button type="info" @click.stop="goBack()">关 闭</el-button>
      </div>

      <!--牵头单位部门选择-->
      <dept-select :visible="deptVisible" @getSelectInfo="getSelectInfo" @cancel="cancelDept"></dept-select>
      <dept-check :visible="supportDeptVisible" @getCheckInfo="getSupportDeptCheckInfo"
                  @cancel="cancelSupportDept"></dept-check>

      <!--选择规划弹出框begin-->
      <el-dialog title="请选择规划" :visible.sync="dialogFormVisible" width="85%">
        <span style="font-size: 17px;font-weight: 600;color: black;margin-left: 27px;">所选规划：{{choosedPlanning}}</span>
        <div class="form-group">
          <span class="form-label">规划名称:</span>
          <input
            type="text"
            name="key"
            v-model="selectedOptions.titleLike"
            id="searchInput"
            ref="searchInput"
            placeholder="请输入规划名称"
            style="width: 500px;"
            @keyup.enter="searchSubmit()"
          >
          <div class="form-submit-dialog">
            <el-button type="warning" size="small" @click.stop="searchSubmit()">查询</el-button>
            <el-button type="info" size="small" @click.stop="searchReset()">重置</el-button>
          </div>
        </div>
        <transition name="fade1">
          <div v-if="!showall">
            <div :class="{showall:true,active:showall}">
              <el-divider></el-divider>
              <avue-search :option="option" v-model="selectedOptions" @change="handleChange"></avue-search>
            </div>
          </div>
        </transition>
        <transition name="fade">
          <div v-if="showall">
            <div :class="{showall:true,active:showall}">
              <el-divider></el-divider>
              <avue-search
                :option="option"
                v-model="selectedOptions"
                @change="handleChange"></avue-search>
            </div>
          </div>
        </transition>
        <div class="search-collapse">
          <div class="collapse-title" :class="{active:showall}" v-on:click="showall=!showall">
            <img v-if="!showall" :src="`${publicPath}img/packdown.png`" class="collapse-title-img">
            <p v-if="!showall" class="collapse-title-text">展开搜索条件0</p>
            <img v-if="showall" :src="`${publicPath}img/packUp.png`" class="collapse-title-img">
            <p v-if="showall" class="collapse-title-text">收起搜索条件</p>
          </div>
        </div>
        <div style="margin-top: 18px;margin-left: 10px;font-weight: 600;">搜索结果列表</div>
        <div class="card-body">
          <avue-crud :data="resultListData"
                     :option="tableoption"
                     :page="page"
                     :table-loading="tableLoading"
                     @on-load="getResultList"
                     @refresh-change="refreshChange"
                     @search-change="searchChange"
                     @current-row-change="handleCurrentRowChange"
                     class="avuecrud">
            <template slot-scope="scope" slot="menu">
              <div class="menu-title" @click.stop="resultDetail(scope.row,scope.index)">
                <i class="iconfont iconview icon-primary"></i>
                <p class="menu-title-text">详情</p>
              </div>
            </template>
          </avue-crud>
        </div>
        <div slot="footer" class="dialog-footer">
          <el-button @click="cancelPlanning()">取 消</el-button>
          <el-button type="primary" @click="confirmPlanning()">确 定</el-button>
        </div>
      </el-dialog>
      <!--选择规划弹出框end-->

      <!--增加指标/任务/项目弹出框begin-->
      <el-dialog :title="TitleByType" :visible.sync="normDialogVisible" width="1000px">
        <el-form
          label-width="130px"
          :model="addNormForm"
          style="padding-right: 30px;"
          :rules="formRulesFlagControl()"
          ref="addNormForm"
        >
          <el-row>
            <el-col :span="22">
              <el-form-item class="form-item" :label="nameItemControl" prop="itemName">
                <el-input
                  placeholder="请输入名称"
                  v-model="addNormForm.itemName"
                ></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="22">
              <el-form-item class="form-item" :label="descriptionItemControl" prop="description">
                <el-input
                  type="textarea"
                  :autosize="{ minRows: 4, maxRows: 4}"
                  placeholder="请输入内容"
                  v-model="addNormForm.description"
                ></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="10">
              <el-form-item class="form-item" label="指标类别 :" prop="classify" v-if="classifyView">
                <el-select
                  v-model="addNormForm.classify"
                  placeholder="请选择"
                  style="width: 280px;"
                >
                  <el-option
                    v-for="item in classifyDIC"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="16">
              <el-form-item label="牵头部门 :" prop="leadDeptName" class="form-item">
                <span style="font-size: 16px">{{addNormForm.leadDeptName}}</span>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-button size="small" type="primary" icon="el-icon-plus" style="margin-left: 10px;"
                         @click="clickMainDept">选择牵头部门
              </el-button>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="16">
              <el-form-item label="配合部门 :" prop="cooDeptName" class="form-item">
                <span style="font-size: 16px">{{addNormForm.cooDeptName}}</span>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-button size="small" type="primary" icon="el-icon-plus" style="margin-left: 10px;"
                         @click="clickAssortDept">选择配合部门
              </el-button>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="10">
              <el-form-item class="form-item" label="基期年 :" prop="basePeriodYear" v-if="basePeriodYearView">
                <el-date-picker
                  v-model="addNormForm.basePeriodYear"
                  type="year"
                  placeholder="选择年份"
                  value-format="yyyy"
                  format="yyyy"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="10">
              <el-form-item class="form-item" label="基数 :" prop="base" v-if="baseView">
                <el-input v-model="addNormForm.base" placeholder="请输入基数"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="10">
              <el-form-item class="form-item" label="起始年份 :" prop="startDate" v-if="startDateView">
                <el-date-picker
                  v-model="addNormForm.startDate"
                  type="year"
                  placeholder="选择年份"
                  value-format="yyyy"
                  format="yyyy"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="10">
              <el-form-item class="form-item" label="目标年份 :" prop="endDate" v-if="endDateView">
                <el-date-picker
                  v-model="addNormForm.endDate"
                  type="year"
                  placeholder="选择年份"
                  value-format="yyyy"
                  format="yyyy"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="10">
              <el-form-item class="form-item" :label="totalTargetLabel" prop="totalTarget" v-if="totalTargetView">
                <el-input v-model="addNormForm.totalTarget" placeholder="请输入总目标"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="10">
              <el-form-item class="form-item" :label="totalTargetUnitLabel" prop="totalTargetUnit"
                            v-if="totalTargetUnitView">
                <el-input v-model="addNormForm.totalTargetUnit" placeholder="请输入总目标单位"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="10">
              <el-form-item class="form-item" label="定性目标 :" prop="totalTarget" v-if="qualitativeTargetView">
                <el-input v-model="addNormForm.qualitativeTarget" placeholder="请输入定性目标"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="10">
              <el-form-item class="form-item" label="是否可量化 :" prop="quantifiable" v-if="quantifiableView">
                <el-select
                  v-model="addNormForm.quantifiable"
                  placeholder="请选择"
                  style="width: 280px;"
                >
                  <el-option
                    v-for="item in quantifiableDIC"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <!--<el-col :span="10">-->
            <!--<el-form-item class="form-item" label="基数 :" prop="base" v-if="baseView">-->
            <!--<el-input v-model="addNormForm.base" placeholder="请输入基数"></el-input>-->
            <!--</el-form-item>-->
            <!--</el-col>-->
          </el-row>
          <el-row>
            <el-col :span="10">
              <el-form-item class="form-item" label="年均增长 :" prop="yearAverageRise" v-if="yearAverageRiseView">
                <el-input v-model="addNormForm.yearAverageRise" placeholder="请输入年均增长"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="10">
              <el-form-item class="form-item" label="属性 :" prop="attribute" v-if="attributeView">
                <el-select
                  v-model="addNormForm.attribute"
                  placeholder="请选择"
                  style="width: 280px;"
                >
                  <el-option
                    v-for="item in attributeDIC"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="20">
              <el-form-item class="form-item" label="时间类型 :" prop="submitPeriod">
                <el-select
                  v-model="addNormForm.submitPeriod"
                  placeholder="请选择"
                  style="width: 280px;"
                >
                  <el-option
                    v-for="item in submitPeriodDIC"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="cancelNormForm()">取 消</el-button>
          <el-button type="primary" @click="confirmNormForm()">确 定</el-button>
        </div>
      </el-dialog>
      <!--增加指标弹出框begin-->

      <!--增加目标弹出框-->
      <el-dialog title="添加目标" :visible.sync="modifyTargetVisible" width="1000px">
        <el-form
          label-width="130px"
          :model="modifyTargetForm"
          style="padding-right: 30px;"
          :rules="modifyTargetRules"
          ref="modifyTargetForm"
        >
          <el-row>
            <el-col :span="18" style="margin-top: 27px;">
              <el-form-item class="form-item" label="年份 :" prop="year">
                <el-date-picker
                  v-model="modifyTargetForm.year"
                  type="year"
                  placeholder="请输入年份"
                  value-format="yyyy"
                  format="yyyy"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="18" style="margin-top: 27px;">
              <el-form-item class="form-item" label="目标值 :" prop="targetValue">
                <el-input v-model="modifyTargetForm.targetValue" placeholder="请输入目标值"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="18" style="margin-top: 27px;">
              <el-form-item class="form-item" label="目标值单位 :" prop="targetValueUnit">
                <el-input v-model="modifyTargetForm.targetValueUnit" placeholder="请输入目标值单位"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="18" style="margin-top: 27px;">
              <el-form-item class="form-item" label="目标内容 :" prop="targetContent">
                <el-input type="textarea" :autosize="{ minRows: 4, maxRows: 4}"
                          v-model="modifyTargetForm.targetContent" placeholder="请输入目标内容"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row style="text-align:center">
            <el-col :span="18" style="width:100%">
              <el-button type="primary" @click="addTarget()">添 加</el-button>
              <el-button @click="modifyTargetVisible=false">关 闭</el-button>
            </el-col>
          </el-row>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <avue-crud
            :data="addTargetListData"
            :option="addTargetOption"
            :page="addTargetpage"
            class="avuecrud"
          >
            <template slot-scope="scope" slot="menu">
              <div class="menu-title" @click.stop="addTargetDelete(scope.row,scope.index)">
                <i class="iconfont iconview icon-primary"></i>
                <p class="menu-title-text">删除</p>
              </div>
            </template>
          </avue-crud>
        </div>
      </el-dialog>
      <!--增加目标弹出框end-->

    </div>
  </basic-container>
</template>

<script>
  import {
    addProgramFormRules,
    addTargetRules,
    addNormFormFormRules,
    addNormFormFormRulesFalse,
    addNormFormFormRulesProject
  } from "@/const/infoRules";
  import {subjectCollection} from "@/api/subject";
  import {addDecomposeDraft} from "@/api/pim/pim";
  import {PROJECT_DIC} from '@/const/dict';
  import {resultPagePim} from "@/api/planning/result";
  import {getAreaByType} from "@/api/system";
  import relatedfile from "@/mixins/relatedfile";
  import {mapGetters} from "vuex";

  export default {
    name: "addProgram",
    computed: {
      ...mapGetters([
        "deptInfo"
      ])
    },
    mixins: [relatedfile],
    created() {
      this.getarea();
      this.getselectedOptionsHistory();
    },
    watch: {
      'selectedOptions.area'(val) {
        var areacode = val.substring(0, 4);
        getAreaByType(Object.assign({
          current: 1,
          size: 200,
          valueLike: areacode,
          type: "area_code_county",
        })).then(response => {
          var records = response.data.data.records;
          var arealist = [];
          arealist.push(this.dictobj);
          for (var item in records) {
            var dictObj = {
              label: records[item].label,
              value: records[item].value
            };
            arealist.push(dictObj)
          }
          this.arealisttempdistrict = arealist;
          for (var item in this.option.column) {
            if (this.option.column[item].prop == "district") {
              this.option.column[item].dicData = this.arealisttempdistrict;
            }
          }
        })
      }
    },
    data() {
      const getYearDic = _ => {
        return [{
          label: '全部',
          value: '-1',
        }].concat(PROJECT_DIC.YEAR)
      };
      const getApplyForCategoryDic = _ => {
        return [{
          label: '全部',
          value: '-1',
        }].concat(PROJECT_DIC.CATEGORY)
      };
      const getPlanningRankDic = _ => {
        return [{
          label: '全部',
          value: '-1',
        }].concat(PROJECT_DIC.PLANNING_RANK)
      };
      const getLevelDic = _ => {
        return [{
          label: '全部',
          value: '-1',
        }].concat(PROJECT_DIC.PLANNING_LEVEL)
      };
      return {
        headerData: {
          title: '编制责任分解方案'
        },
        addProgramFormRules: addProgramFormRules,// 表单验证
        projectForm: {
          description: '',
          fileIds: [],
          planningTitle: '',
          pmuc: '',
          itemTargetList: [],
          itemTaskList: [],
          itemProjectList: [],
          targetDTOList: [],
        },
        deptVisible: false,//协同部门树弹窗标志
        supportDeptVisible: false,//协同部门树弹窗标志
        singletableoption: {
          page: false,
          menuWidth: 150,
          addBtn: false,
          editBtn: false,
          addRowBtn: false,
          indexLabel: "序号",
          index: true,
          indexWidth:70,
          cellBtn: false,
          delBtn: false,
          columnBtn: false,
          refreshBtn: false,
          filterBtn: false,
          searchBtn: false,
          keyId: "id",
          column: [{
            label: "年份",
            prop: "year",
            cell: true,
          },
            {
              label: "规划名称",
              width: 200,
              prop: "title",
              cell: true
            },
            {
              label: "规划编码",
              prop: "pmuc",
              width: 200,
              cell: true,
            },
            {
              label: "申报单位",
              prop: "orgName",
              cell: true,
            },
            {
              label: "规划类型",
              prop: "category",
              type: "select",
              dicData: PROJECT_DIC.CATEGORY,
              cell: true
            },
            {
              label: "联系人姓名",
              prop: "contactName",
              cell: true,
            },
            {
              label: "联系人电话",
              prop: "contactNumber",
              cell: true,
            },
          ]
        },
        singletableLoading: false,
        singleresultListData: [],
        dialogFormVisible: false,
        state: '0,1,2,3',//状态
        page: {
          total: 0, // 总页数
          currentPage: 1, // 当前页数
          pageSize: 10 // 每页显示多少条
        },
        tableLoading: false,
        resultListData: [],
        tableoption: {
          highlightCurrentRow: true,
          page: true,
          menuWidth: 150,
          addBtn: false,
          editBtn: false,
          addRowBtn: false,
          indexLabel: "序号",
          index: true,
          indexWidth:70,
          cellBtn: false,
          delBtn: false,
          columnBtn: false,
          refreshBtn: false,
          filterBtn: false,
          searchBtn: false,
          keyId: "id",
          column: [{
            label: "年份",
            prop: "year",
            cell: true,
          },
            {
              label: "规划名称",
              width: 200,
              prop: "title",
              cell: true
            },
            {
              label: "规划编码",
              prop: "pmuc",
              width: 200,
              cell: true,
            },
            {
              label: "申报单位",
              prop: "orgName",
              cell: true,
            },
            {
              label: "规划类型",
              prop: "category",
              type: "select",
              dicData: PROJECT_DIC.CATEGORY,
              cell: true
            },
            {
              label: "联系人姓名",
              prop: "contactName",
              cell: true,
            },
            {
              label: "联系人电话",
              prop: "contactNumber",
              cell: true,
            },
          ]
        },
        option: {
          column: [
            {
              label: "年份",
              prop: "year",
              multiple: false,
              dicData: getYearDic()
            },
            {
              label: "规划类型",
              prop: "categorys",
              multiple: false,
              dicData: getApplyForCategoryDic()
            },
            {
              label: "发布等级",
              prop: "planningRanks",
              multiple: false,
              dicData: getPlanningRankDic()
            },
            {
              label: "发布层级",
              prop: "planningLevels",
              multiple: false,
              dicData: getLevelDic()
            },
            {
              label: "市级",
              prop: "area",
              multiple: false,
              dicData: this.getarea,
            },
            {
              label: "区县",
              prop: "district",
              multiple: false,
              dicData: this.arealisttempdistrict,
            },
          ]
        },
        selectedOptions: {
          categorys: "-1",
          planningRanks: "-1",
          planningLevels: "-1",
          area: '-1',
          district: '-1',
          year: '-1',
          titleLike: ''
        },
        resetSelectedOptions: {
          categorys: "-1",
          planningRanks: "-1",
          planningLevels: "-1",
          area: '-1',
          areCode: '-1',
          district: '-1',
          year: '-1',
          titleLike: ''
        },
        selectedOptionsHistory: {
          categorys: "-1",
          planningRanks: "-1",
          planningLevels: "-1",
          area: '-1',
          district: '-1',
          year: '-1',
          titleLike: ''
        },
        showall: false,
        publicPath: process.env.BASE_URL,
        dictobj: {
          label: '全部',
          value: '-1',
        },
        arealisttemp: [],
        arealisttempdistrict: [],
        choosedPlanning: '',
        choosedPlanningTemp: {
          achievementId: 0,
        },
        // 立项依据
        basisContent: '',
        basisOption: {
          // something config
          modules: {
            toolbar: null
          },
          placeholder: '请输入立项依据'
        },
        isDisabled: false,
        expireTimeOption: {
          disabledDate(date) { //disabledDate 文档上：设置禁用状态，参数为当前日期，要求返回 Boolean
            return date.getTime() <= Date.now();
          }
        },
        activeNames: ['1', '2', '3'],
        formRulesFlag: '0',
        addNormFormFormRules: addNormFormFormRules,
        addNormFormFormRulesFalse: addNormFormFormRulesFalse,
        addNormFormFormRulesProject: addNormFormFormRulesProject,
        normListData: [],//真正的数据
        normListDataPage: [],//用于分页显示的数据
        normTableOption: {
          page: true,
          menuWidth: 200,
          addBtn: false,
          editBtn: false,
          addRowBtn: false,
          indexLabel: "序号",
          index: true,
          indexWidth:70,
          cellBtn: false,
          delBtn: false,
          columnBtn: false,
          refreshBtn: false,
          filterBtn: false,
          searchBtn: false,
          keyId: "id",
          column: [
            {
              label: "指标名称",
              prop: "itemName",
              cell: true
            },
            {
              label: "基数",
              prop: "base",
              cell: true,
            },
            {
              label: "总目标",
              prop: "totalTarget",
              cell: true,
              formatter: function (row, value, label, column) {
                return '<a>' + row.totalTarget + row.totalTargetUnit + '</a>';
              },
            },
            {
              label: "指标内容",
              prop: "description",
              cell: true,
              overHidden: true
            },
            {
              label: "起止日期",
              cell: true,
              formatter: function (row, value, label, column) {
                return '<a>' + row.startDate + '-' + row.endDate + '</a>';
              },
            },
            {
              label: "牵头部门",
              prop: "leadDeptName",
              cell: true
            },
            {
              label: "配合部门",
              prop: "cooDeptName",
              cell: true,
            },
          ]
        },
        normPage: {
          total: 0, // 总页数
          currentPage: 1, // 当前页数
          pageSize: 10 // 每页显示多少条
        },
        normTableLoading: false,
        taskListData: [],
        taskListDataPage: [],
        taskTableOption: {
          page: true,
          menuWidth: 100,
          addBtn: false,
          editBtn: false,
          addRowBtn: false,
          indexLabel: "序号",
          index: true,
          indexWidth:70,
          cellBtn: false,
          delBtn: false,
          columnBtn: false,
          refreshBtn: false,
          filterBtn: false,
          searchBtn: false,
          keyId: "id",
          column: [
            {
              label: "任务名称",
              prop: "itemName",
              cell: true
            },
            {
              label: "任务内容",
              prop: "description",
              cell: true,
              overHidden: true
            },
            {
              label: "起止日期",
              cell: true,
              formatter: function (row, value, label, column) {
                return '<a>' + row.startDate + '-' + row.endDate + '</a>';
              },
            },
            {
              label: "牵头部门",
              prop: "leadDeptName",
              cell: true
            },
            {
              label: "配合部门",
              prop: "cooDeptName",
              cell: true,
            },
          ]
        },
        taskPage: {
          total: 0, // 总页数
          currentPage: 1, // 当前页数
          pageSize: 10 // 每页显示多少条
        },
        taskTableLoading: false,
        projectListData: [],
        projectListDataPage: [],
        projectTableOption: {
          page: true,
          menuWidth: 200,
          addBtn: false,
          editBtn: false,
          addRowBtn: false,
          indexLabel: "序号",
          index: true,
          indexWidth:70,
          cellBtn: false,
          delBtn: false,
          columnBtn: false,
          refreshBtn: false,
          filterBtn: false,
          searchBtn: false,
          keyId: "id",
          column: [
            {
              label: "项目名称",
              prop: "itemName",
              cell: true
            },
            {
              label: "总目标",
              prop: "totalTarget",
              cell: true,
              formatter: function (row, value, label, column) {
                return '<a>' + row.totalTarget + row.totalTargetUnit + '</a>';
              },
            },
            {
              label: "项目内容",
              prop: "description",
              cell: true,
              overHidden: true
            },
            {
              label: "起止日期",
              cell: true,
              formatter: function (row, value, label, column) {
                return '<a>' + row.startDate + '-' + row.endDate + '</a>';
              },
            },
            {
              label: "牵头部门",
              prop: "leadDeptName",
              cell: true
            },
            {
              label: "配合部门",
              prop: "cooDeptName",
              cell: true,
            },
          ]
        },
        projectPage: {
          total: 0, // 总页数
          currentPage: 1, // 当前页数
          pageSize: 10 // 每页显示多少条
        },
        projectTableLoading: false,

        normDialogVisible: false,
        addNormForm: {
          leadDeptName: '',
          description: '',
          leadDeptId: '',
          cooDeptName: '',
          cooDeptId: '',
          startDate: '',
          endDate: '',
          totalTarget: '',
          totalTargetUnit: '',
          quantifiable: '',
          itemName: '',
          content: '',
          base: '',
          yearAverageRise: '',
          attribute: '',
          classify: '',
          qualitativeTarget: '',
          basePeriodYear: '',
          submitPeriod: '',
        },
        serialNumber: 1,
        dutyType: '',//区分是添加指标，任务，还是项目
        TitleByType: '',
        modifyTargetVisible: false,
        modifyTargetForm: {
          year: '',
          targetValue: '',
          targetValueUnit: '',
          targetContent: '',
          ditemFakeId: '',
        },
        modifyTargetRules: addTargetRules,
        addTargetListData: [],
        addTargetOption: {
          page: true,
          addBtn: false,
          editBtn: false,
          indexLabel: "序号",
          index: true,
          indexWidth:70,
          cellBtn: false,
          delBtn: false,
          columnBtn: false,
          refreshBtn: false,
          filterBtn: false,
          searchBtn: false,
          menuWidth: 100,
          keyId: "id",
          column: [{
            label: "年份",
            prop: "year",
            cell: true
          },
            {
              label: "目标值",
              width: 250,
              prop: "targetValue",
              cell: true
            },
            {
              label: "目标值单位",
              width: 200,
              prop: "targetValueUnit",
              cell: true
            },
            {
              label: "目标内容",
              width: 250,
              prop: "targetContent",
              cell: true
            },
          ]
        },
        addTargetpage: {
          total: 0, // 总页数
          currentPage: 1, // 当前页数
          pageSize: 10 // 每页显示多少条
        },
        addTargetType: '',
        addTargetListNorm: [],
        addTargetListTask: [],
        addTargetListProject: [],
        ditemFakeId: 1,
        quantifiableDIC: [
          {
            label: "是",
            value: true
          },
          {
            label: "否",
            value: false
          },
        ],
        attributeDIC: [
          {
            label: "预期性",
            value: "0"
          },
          {
            label: "约束性",
            value: "1"
          },
        ],
        classifyDIC: [
          {
            label: "经济发展",
            value: "1"
          },
          {
            label: "创新驱动",
            value: "2"
          },
          {
            label: "民生福祉",
            value: "3"
          },
          {
            label: "资源环境",
            value: "4"
          },
        ],
        submitPeriodDIC: [
          {
            label: "年报",
            value: "1"
          },
          // {
          //   label: "季报",
          //   value: "2"
          // },
          // {
          //   label: "月报",
          //   value: "3"
          // },
        ],
        totalTargetView: true,
        totalTargetUnitView: true,
        baseView: true,
        basePeriodYearView: true,
        yearAverageRiseView: true,
        attributeView: true,
        startDateView: true,
        endDateView: true,
        quantifiableView: true,
        classifyView: true,
        qualitativeTargetView: true,
        nameItemControl: '',
        contentItemControl: '',
        descriptionItemControl: '',
        totalTargetLabel: '总目标',
        totalTargetUnitLabel: '总目标单位',

      }
    },
    methods: {
      // 弹出选择牵头部门弹框
      clickMainDept() {
        this.deptVisible = true
      },
      cancelDept(deptIds, deptNames) {
        this.deptVisible = false;
      },
      getSelectInfo(deptId, deptName) {
        this.addNormForm.leadDeptName = deptName;
        this.addNormForm.leadDeptId = deptId;
        this.deptVisible = false;
      },
      //弹出选择配合部门弹框
      clickAssortDept() {
        this.supportDeptVisible = true;
      },
      cancelSupportDept() {
        this.supportDeptVisible = false;
      },
      getSupportDeptCheckInfo(deptIds, deptNames) {
        this.addNormForm.cooDeptName = deptNames;
        this.addNormForm.cooDeptId = deptIds;
        this.supportDeptVisible = false;
      },

      goBack() {
        this.$router.go(-1);
      },
      commitList() {
        if (this.projectForm.pmuc == '') {
          this.$notify({
            title: "提醒",
            type: "warning",
            message: "请选择规划",
            duration: 2000
          });
          return;
        }
        if (this.projectListData.length == 0 && this.taskListData.length == 0 && this.normListData.length == 0) {
          this.$notify({
            title: "提醒",
            type: "warning",
            message: "请至少分配一项指标，任务或项目",
            duration: 2000
          });
          return;
        }

        this.$refs.projectForm.validate(valid => {
          if (valid) {
            this.$confirm("确定发送方案吗?", "提示", {
              confirmButtonText: "确定",
              cancelButtonText: "取消",
              type: "warning"
            }).then(() => {
              var arr = [];
              for (var item in this.fileListMixin) {
                arr.push(this.fileListMixin[item].url);
              }
              this.projectForm.fileIds = arr;

              this.projectForm.itemTargetList = this.normListData;
              this.projectForm.itemTaskList = this.taskListData;
              this.projectForm.itemProjectList = this.projectListData;
              var arr = this.addTargetListNorm.concat(this.addTargetListTask);
              this.projectForm.targetDTOList = arr.concat(this.addTargetListProject);
              this.isDisabled = true;

              addDecomposeDraft(this.projectForm).then(response => {
                if (response.data.code == 0) {
                  this.$notify({
                    title: "成功",
                    message: "发送成功",
                    type: "success",
                    duration: 2000
                  });
                  this.$router.go(-1);
                }
              })
            });
            this.isDisabled = false;
          } else {
            this.isDisabled = false;
          }
        })
      },
      choosePlanning() {
        this.dialogFormVisible = true;
      },
      cancelPlanning() {
        this.dialogFormVisible = false;
      },
      getResultList(page) {
        this.tableLoading = true;
        sessionStorage.setItem('addProgram.categorysLevy', this.selectedOptions.categorys);
        sessionStorage.setItem('addProgram.planningRanksLevy', this.selectedOptions.planningRanks);
        sessionStorage.setItem('addProgram.planningLevelsLevy', this.selectedOptions.planningLevels);
        sessionStorage.setItem('addProgram.areaLevy', this.selectedOptions.area);
        sessionStorage.setItem('addProgram.districtLevy', this.selectedOptions.district);
        sessionStorage.setItem('addProgram.yearLevy', this.selectedOptions.year);
        sessionStorage.setItem('addProgram.titleLikeLevy', this.selectedOptions.titleLike);
          resultPagePim(Object.assign({
          current: page.currentPage,
          size: page.pageSize,
          states: this.state,
        }, this.filterFormData(this.selectedOptions))).then(response => {
          this.resultListData = response.data.data.records;
          this.page.total = response.data.data.total;
          this.tableLoading = false
        })
      },
      refreshChange() {
        this.getResultList(this.page)
      },
      // 搜索
      searchChange(params) {
        this.page.currentPage = 1
        this.getResultList(this.page, this.dealSearchParam(params))
      },
      // 处理搜索过滤
      dealSearchParam(params) {
        if (params.title) {
          params.titleLike = params.title;
          params.title = ''
        }
        if (params.category) {
          params.categorys = params.category;
          params.category = ''
        }
        return params;
      },
      // 成果详情跳转
      resultDetail(row, index) {
        let src = `/searchDetail/detail/${row.achievementId}`;
        this.$router.push({
          path: src
        })
      },
      // 成果详情跳转
      resultDetailTemp() {
        let src = `/searchDetail/detail/${this.projectForm.achievementId}`;
        this.$router.push({
          path: src
        })
      },
      searchSubmit() {
        if (this.selectedOptions.district != -1 && this.selectedOptions.district != '') {
          this.selectedOptions.areaCode = this.selectedOptions.district
        } else {
          this.selectedOptions.areaCode = this.selectedOptions.area
        }
        this.selectedOptions.areaCode = this.selectedOptions.areaCode.substring(0, 6);
        this.getResultList(this.page)
      },
      searchReset() {
        this.selectedOptions = this.resetSelectedOptions;
        this.getResultList(this.page)
      },
      handleChange(form) {

      },
      getarea() {
        let provinceCode = this.deptInfo.areaCode.substring(0, 2);
        getAreaByType(Object.assign({
          current: 1,
          size: 200,
          valueLike: provinceCode,
          type: "area_code_city"
        })).then(response => {
          var records = response.data.data.records;
          var arealist = [];
          arealist.push(this.dictobj);
          for (var item in records) {
            var dictObj = {
              label: records[item].label,
              value: records[item].value
            };
            arealist.push(dictObj)
          }
          this.arealisttemp = arealist;
          for (var item in this.option.column) {
            if (this.option.column[item].prop == "area") {
              this.option.column[item].dicData = this.arealisttemp;
            }
          }
        })
      },
      filterFormData(form) {
        var formMap = {};
        Object.keys(form).forEach(function (name) {
          if (form[name] != -1) {
            formMap[name] = form[name]
          }
        });
        return formMap;
      },
      getselectedOptionsHistory() {
        if (sessionStorage.getItem('addProgram.categorysLevy') != null) {
          this.selectedOptionsHistory.categorys = sessionStorage.getItem('addProgram.categorysLevy')
        }
        if (sessionStorage.getItem('addProgram.planningRanksLevy') != null) {
          this.selectedOptionsHistory.planningRanks = sessionStorage.getItem('addProgram.planningRanksLevy')
        }
        if (sessionStorage.getItem('addProgram.planningLevelsLevy') != null) {
          this.selectedOptionsHistory.planningLevels = sessionStorage.getItem('addProgram.planningLevelsLevy')
        }
        if (sessionStorage.getItem('addProgram.districtLevy') != null) {
          this.selectedOptionsHistory.district = sessionStorage.getItem('addProgram.districtLevy')
        }
        if (sessionStorage.getItem('addProgram.yearLevy') != null) {
          this.selectedOptionsHistory.year = sessionStorage.getItem('addProgram.yearLevy')
        }
        if (sessionStorage.getItem('addProgram.areaLevy') != null) {
          this.selectedOptionsHistory.area = sessionStorage.getItem('addProgram.areaLevy')
        }
        if (sessionStorage.getItem('addProgram.titleLikeLevy') != null) {
          this.selectedOptionsHistory.titleLike = sessionStorage.getItem('addProgram.titleLikeLevy')
        }
        var selectedOptionsHistory = this.selectedOptionsHistory;
        this.selectedOptions = selectedOptionsHistory;
        if (this.selectedOptions.district != -1 && this.selectedOptions.district != '') {
          this.selectedOptions.areaCode = this.selectedOptions.district
        } else {
          this.selectedOptions.areaCode = this.selectedOptions.area
        }
        this.selectedOptions.areaCode = this.selectedOptions.areaCode.substring(0, 6)
      },
      handleCurrentRowChange(val) {
        this.choosedPlanningTemp = val;
        this.choosedPlanning = val.title;
        this.$notify({
          showClose: true,
          message: '已选规划： ' + val.title,
          type: 'success',
        });
      },
      confirmPlanning() {
        if (this.choosedPlanningTemp.achievementId == 0) {
          this.$notify({
            title: "提醒",
            type: "warning",
            message: "请选择规划",
            duration: 2000
          });
          return;
        }
        this.singleresultListData = [this.choosedPlanningTemp];
        this.dialogFormVisible = false;
        this.projectForm.achievementId = this.choosedPlanningTemp.achievementId;
        this.projectForm.planningTitle = this.choosedPlanningTemp.title;
        this.projectForm.description = "\"" + this.choosedPlanningTemp.title + "\"责任分解方案";
        this.projectForm.pmuc = this.choosedPlanningTemp.pmuc;
      },
      getNormList() {
      },
      getTaskList() {
      },
      getProjectList() {
      },
      addNorm(type) {
        if(this.choosedPlanningTemp.startDate==undefined){
          this.$notify({
            title: '提示',
            message: '请选择规划',
            type: 'warning',
            duration: 2000
          });
          return;
        }
        switch (type) {
          case '0':
            this.TitleByType = '添加指标';
            this.dutyType = '0';
            this.addNormForm.quantifiable = true;
            this.totalTargetView = true;
            this.totalTargetUnitView = true;
            this.baseView = true;
            this.basePeriodYearView = true;
            this.yearAverageRiseView = true;
            this.attributeView = true;
            this.startDateView = true;
            this.endDateView = true;
            this.quantifiableView = true;
            this.classifyView = true;
            this.qualitativeTargetView = false;
            this.formRulesFlag = '0';
            this.nameItemControl = '指标名称 :';
            this.descriptionItemControl = '指标说明 :';
            this.totalTargetLabel = '总目标 :';
            this.totalTargetUnitLabel = '总目标单位 :';
            this.addNormForm.basePeriodYear = (this.choosedPlanningTemp.startDate - 1).toString();
            break;
          case '1':
            this.TitleByType = '添加任务';
            this.dutyType = '1';
            this.addNormForm.quantifiable = false;
            this.totalTargetView = false;
            this.totalTargetUnitView = false;
            this.baseView = false,
              this.basePeriodYearView = false,
              this.yearAverageRiseView = false,
              this.attributeView = false,
              this.startDateView = true,
              this.endDateView = true,
              this.quantifiableView = false;
            this.classifyView = false;
            this.qualitativeTargetView = false;
            this.formRulesFlag = '1';
            this.nameItemControl = '任务名称 :';
            this.descriptionItemControl = '任务内容 :';
            this.totalTargetLabel = '总目标 :';
            this.totalTargetUnitLabel = '总目标单位 :';
            this.addNormForm.startDate = '';
            this.addNormForm.endDate = '';
            break;
          case '2':
            this.TitleByType = '添加项目';
            this.dutyType = '2';
            this.addNormForm.quantifiable = true;
            this.totalTargetView = true;
            this.totalTargetUnitView = true;
            this.baseView = false,
              this.basePeriodYearView = false,
              this.yearAverageRiseView = false,
              this.attributeView = false,
              this.startDateView = true,
              this.endDateView = true,
              this.quantifiableView = false;
            this.classifyView = false;
            this.qualitativeTargetView = true;
            this.formRulesFlag = '2';
            this.nameItemControl = '项目名称 :';
            this.descriptionItemControl = '项目内容 :';
            this.totalTargetLabel = '定量目标 :';
            this.totalTargetUnitLabel = '定量目标单位 :';
            this.addNormForm.startDate = '';
            this.addNormForm.endDate = '';
            break;

        }
        this.addNormForm.startDate = this.choosedPlanningTemp.startDate.toString();
        this.addNormForm.endDate = this.choosedPlanningTemp.endDate.toString();
        this.addNormForm.cooDeptName = '';
        this.addNormForm.cooDeptId = '';
        this.addNormForm.leadDeptName = '';
        this.addNormForm.leadDeptId = '';
        this.addNormForm.description = '';
        this.addNormForm.totalTarget = '';
        this.addNormForm.totalTargetUnit = '';
        this.addNormForm.base = '';
        this.addNormForm.yearAverageRise = '';
        this.addNormForm.attribute = '';
        this.addNormForm.itemName = '';
        this.addNormForm.qualitativeTarget = '';
        this.addNormForm.submitPeriod = '1';
        this.normDialogVisible = true;
      },

      cancelNormForm() {
        this.normDialogVisible = false;
      },
      confirmNormForm() {
        if (this.addNormForm.leadDeptId == '') {
          this.$notify({
            title: '提示',
            message: '请选择牵头部门',
            type: 'warning',
            duration: 2000
          });
          return;
        }
        // if (this.addNormForm.cooDeptId == '') {
        //   this.$notify({
        //     title: '提示',
        //     message: '请选择配合部门',
        //     type: 'warning',
        //     duration: 2000
        //   });
        //   return;
        // }
        this.$refs.addNormForm.validate(valid => {
          if (valid) {
            if (this.dutyType == '0') {
              this.normListData.push(
                {
                  ditemFakeId: this.serialNumber, description: this.addNormForm.description,
                  itemName: this.addNormForm.itemName, quantifiable: this.addNormForm.quantifiable,
                  leadDeptName: this.addNormForm.leadDeptName, cooDeptName: this.addNormForm.cooDeptName,
                  leadDeptId: this.addNormForm.leadDeptId, cooDeptId: this.addNormForm.cooDeptId,
                  totalTarget: this.addNormForm.totalTarget, totalTargetUnit: this.addNormForm.totalTargetUnit,
                  startDate: this.addNormForm.startDate, endDate: this.addNormForm.endDate,
                  dateformat: this.addNormForm.startDate + '-' + this.addNormForm.endDate,
                  totalTargetformat: this.addNormForm.totalTarget + this.addNormForm.totalTargetUnit,
                  base: this.addNormForm.base, yearAverageRise: this.addNormForm.yearAverageRise,
                  attribute: this.addNormForm.attribute, classify: this.addNormForm.classify,
                  basePeriodYear: this.addNormForm.basePeriodYear, submitPeriod: this.addNormForm.submitPeriod,
                }
              );
              this.serialNumber = this.serialNumber + 1;
              this.normPage.total = this.normListData.length;
              this.pageForType('0', this.normPage.currentPage, this.normPage.pageSize);

            } else if (this.dutyType == '1') {
              this.taskListData.push(
                {
                  ditemFakeId: this.serialNumber, description: this.addNormForm.description,
                  itemName: this.addNormForm.itemName,
                  startDate: this.addNormForm.startDate, endDate: this.addNormForm.endDate,
                  leadDeptName: this.addNormForm.leadDeptName, cooDeptName: this.addNormForm.cooDeptName,
                  leadDeptId: this.addNormForm.leadDeptId, cooDeptId: this.addNormForm.cooDeptId,
                  submitPeriod: this.addNormForm.submitPeriod,
                }
              );
              this.serialNumber = this.serialNumber + 1;
              this.taskPage.total = this.taskListData.length;
              this.pageForType('1', this.taskPage.currentPage, this.taskPage.pageSize);

            } else if (this.dutyType == '2') {
              this.projectListData.push(
                {
                  ditemFakeId: this.serialNumber, description: this.addNormForm.description,
                  itemName: this.addNormForm.itemName, quantifiable: this.addNormForm.quantifiable,
                  leadDeptName: this.addNormForm.leadDeptName, cooDeptName: this.addNormForm.cooDeptName,
                  leadDeptId: this.addNormForm.leadDeptId, cooDeptId: this.addNormForm.cooDeptId,
                  totalTarget: this.addNormForm.totalTarget, totalTargetUnit: this.addNormForm.totalTargetUnit,
                  startDate: this.addNormForm.startDate, endDate: this.addNormForm.endDate,
                  dateformat: this.addNormForm.startDate + '-' + this.addNormForm.endDate,
                  totalTargetformat: this.addNormForm.totalTarget + this.addNormForm.totalTargetUnit,
                  qualitativeTarget: this.addNormForm.qualitativeTarget, submitPeriod: this.addNormForm.submitPeriod,
                }
              );
              this.serialNumber = this.serialNumber + 1;
              this.projectPage.total = this.projectListData.length;
              this.pageForType('2', this.projectPage.currentPage, this.projectPage.pageSize);
            }
            this.normDialogVisible = false;
          }
        })
      },
      normcurrentChange(currentPage) {
        this.normPage.currentPage = currentPage;
        this.pageForType('0', currentPage, this.normPage.pageSize);
      },
      normsizeChange(pageSize) {
        this.normPage.pageSize = pageSize;
        this.pageForType('0', this.normPage.currentPage, pageSize);
      },
      taskcurrentChange(currentPage) {
        this.taskPage.currentPage = currentPage;
        this.pageForType('1', currentPage, this.taskPage.pageSize);
      },
      tasksizeChange(pageSize) {
        this.taskPage.pageSize = pageSize;
        this.pageForType('1', this.taskPage.currentPage, pageSize);
      },
      projectcurrentChange(currentPage) {
        this.projectPage.currentPage = currentPage;
        this.pageForType('2', currentPage, this.projectPage.pageSize);
      },
      projectsizeChange(pageSize) {
        this.projectPage.pageSize = pageSize;
        this.pageForType('2', this.projectPage.currentPage, pageSize);
      },
      pageForType(type, currentPage, pageSize) {
        switch (type) {
          case '0' :
            this.normListDataPage = this.normListData.slice(pageSize * (currentPage - 1), pageSize * currentPage);
            break;
          case '1' :
            this.taskListDataPage = this.taskListData.slice(pageSize * (currentPage - 1), pageSize * currentPage);
            break;
          case '2' :
            this.projectListDataPage = this.projectListData.slice(pageSize * (currentPage - 1), pageSize * currentPage);
            break;
        }
      },
      normDelete(row) {
        this.$confirm("确定删除吗?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(() => {
          this.normListData = this.normListData.filter(item => item.ditemFakeId != row.ditemFakeId);
          this.normPage.total = this.normListData.length;
          this.pageForType('0', this.normPage.currentPage, this.normPage.pageSize);
        })
      },
      taskDelete(row) {
        this.$confirm("确定删除吗?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(() => {
          this.taskListData = this.taskListData.filter(item => item.ditemFakeId != row.ditemFakeId);
          this.taskPage.total = this.taskListData.length;
          this.pageForType('1', this.taskPage.currentPage, this.taskPage.pageSize);
        })
      },
      projectDelete(row) {
        this.$confirm("确定删除吗?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(() => {
          this.projectListData = this.projectListData.filter(item => item.ditemFakeId != row.ditemFakeId);
          this.projectPage.total = this.projectListData.length;
          this.pageForType('2', this.projectPage.currentPage, this.projectPage.pageSize);
        })
      },
      addTargetDialogNorm(row) {
        this.ditemFakeId = row.ditemFakeId;
        this.addTargetType = '0';
        this.addTargetListData = this.addTargetListNorm.filter(item => item.ditemFakeId == row.ditemFakeId);
        this.modifyTargetVisible = true;
      },
      addTargetDialogTask(row) {
        this.ditemFakeId = row.ditemFakeId;
        this.addTargetType = '1';
        this.addTargetListData = this.addTargetListTask.filter(item => item.ditemFakeId == row.ditemFakeId);
        this.modifyTargetVisible = true;
      },
      addTargetDialogProject(row) {
        this.ditemFakeId = row.ditemFakeId;
        this.addTargetType = '2';
        this.addTargetListData = this.addTargetListProject.filter(item => item.ditemFakeId == row.ditemFakeId);
        this.modifyTargetVisible = true;
      },
      addTarget() {
        this.modifyTargetForm.ditemFakeId = this.ditemFakeId;
        this.$refs.modifyTargetForm.validate(valid => {
          if (valid) {
            this.addTargetListData.push(
              {
                ditemFakeId: this.ditemFakeId, year: this.modifyTargetForm.year,
                targetValue: this.modifyTargetForm.targetValue, targetValueUnit: this.modifyTargetForm.targetValueUnit,
                targetContent: this.modifyTargetForm.targetContent
              }
            );
            this.serialNumber = this.serialNumber + 1;

            if (this.addTargetType == '0') {
              this.addTargetListNorm.push(
                {
                  ditemFakeId: this.ditemFakeId,
                  year: this.modifyTargetForm.year,
                  targetValue: this.modifyTargetForm.targetValue,
                  targetValueUnit: this.modifyTargetForm.targetValueUnit,
                  targetContent: this.modifyTargetForm.targetContent
                }
              );
            } else if (this.addTargetType == '1') {
              this.addTargetListTask.push(
                {
                  ditemFakeId: this.ditemFakeId,
                  year: this.modifyTargetForm.year,
                  targetValue: this.modifyTargetForm.targetValue,
                  targetValueUnit: this.modifyTargetForm.targetValueUnit,
                  targetContent: this.modifyTargetForm.targetContent
                }
              );
            } else if (this.addTargetType == '2') {
              this.addTargetListProject.push(
                {
                  ditemFakeId: this.ditemFakeId,
                  year: this.modifyTargetForm.year,
                  targetValue: this.modifyTargetForm.targetValue,
                  targetValueUnit: this.modifyTargetForm.targetValueUnit,
                  targetContent: this.modifyTargetForm.targetContent
                }
              );
            }
          }
        })
      },
      addTargetDelete(row) {
        this.$confirm("确定删除吗?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(() => {
          this.addTargetListData = this.addTargetListData.filter(item => item.ditemFakeId != row.ditemFakeId);
          this.addTargetListNorm = this.addTargetListNorm.filter(item => item.ditemFakeId != row.ditemFakeId);
          this.addTargetListTask = this.addTargetListTask.filter(item => item.ditemFakeId != row.ditemFakeId);
          this.addTargetListProject = this.addTargetListProject.filter(item => item.ditemFakeId != row.ditemFakeId);
        })
      },
      formRulesFlagControl() {
        switch (this.formRulesFlag) {
          case '0':
            return this.addNormFormFormRulesFalse;
            break;
          case '1':
            return this.addNormFormFormRules;
            break;
          case '2':
            return this.addNormFormFormRulesProject;
            break;
        }
      },

    },
  }
</script>


<style lang="scss" scoped>
  /deep/ .avue-search__title {
    padding: 0 26px;
    margin-left: -13px;
  }

  table.gridtable {
    width: 100%;
    font-family: verdana, arial, sans-serif;
    font-size: 11px;
    color: #333333;
    border-width: 1px;
    border-color: grey;
    border-collapse: collapse;
  }

  table.gridtable th {
    border-width: 1px;
    width: 20%;
    padding: 8px;
    border-style: solid;
    border-color: #666666;
  }

  table.gridtable td {
    border-width: 1px;
    padding: 8px;
    border-style: solid;
    border-color: #666666;
    background-color: #ffffff;
  }

  .card-border {
    border: 1px solid #d2d2d2;
    padding: 12px;
  }

  .form-submit {
    text-align: center;
    margin-top: 15px;
  }

  .card-body {
    padding: 10px;
  }

  .head-button .el-button {
    padding: 8px 15px;
  }

  .form-item {
    font-weight: 600;
  }

  .form-group {
    margin-top: 1rem;
    margin-left: 26px;
  }

  .form-label {
    font-weight: 600;
    margin-right: 2rem;
  }

  .form-submit-dialog {
    float: right;
    margin-right: 22px;
  }

  .search-collapse {
    margin-top: 1rem;
  }

  .collapse-title {
    margin-top: -1rem;
    text-align: center;
    border-top: 1px solid #dedbdb;
    border-bottom: 1px solid #dedbdb;
  }

  .collapse-title-text {
    color: #4297dc;
    display: inline-block;
    font-size: 15px;
    font-weight: 600;
    margin-left: 0.2rem;
    margin: 10px 0px;
  }

  .collapse-title-img {
    width: 1.2rem;
    position: relative;
    top: 0.25rem;
  }

  .showall {
    padding: 10px;
    height: 0px;
    overflow: hidden;

    .fade-enter-active {
      transition: opacity 0.9s ease-out;
    }

    .fade-leave-active {
      transition: opacity 0s ease-out;
    }

    .fade-enter, .fade-leave-to {
      opacity: 0;
    }

    .fade1-enter-active {
      transition: opacity 0.9s ease-out;
    }

    .fade1-enter, .fade1-leave-to {
      opacity: 0;
    }

    clear: both;
  }

  .showall.active {
    height: auto;
    background: #fff;
    min-height: 150px;
  }

  #searchInput {
    height: 40px;
    border: 1px solid #dadada;
    outline: 0;
    line-height: 40px;
    text-indent: 1rem;
    border-radius: 0.31rem;
  }

  .table-bordered-temp {
    border: 1px solid #dee2e6;
  }

  .table-temp {
    width: 100%;
    margin-bottom: 1rem;
    color: #212529;
    border-collapse: collapse;
  }
  /deep/.avue-search__tags--active {
    color: #fff;
    background-color: #1890ff;
    border-radius: 5px;
    padding: 5px 10px;
  }
</style>



